Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a utility function to GeometryOpsCore, to get geometries from any data structure #240

Open
wants to merge 1 commit into
base: as/usecore
Choose a base branch
from

Conversation

asinghvi17
Copy link
Member

a generic utility inspired by similar functions in Rasters.jl and elsewhere - returns a vector of the geometries in a given object, be it a feature collection, table, iterable of geometries, or whatever.

Potential next steps:

  • get_geometries(x) do geom that rebuilds the given structure as far as possible - this is the same as apply(::AbstractGeometryTrait) though....
  • treatment of dataframes with multiple columns

Also: do we want this here? in GeoInterface?

a generic utility inspired by similar functions in Rasters.jl and elsewhere - returns a vector of the geometries in a given object, be it a feature collection, table, iterable of geometries, or whatever.

Potential next steps:
- `get_geometries(x) do geom` that rebuilds the given structure as far as possible - this is the same as `apply(::AbstractGeometryTrait)` though....
- treatment of dataframes with multiple columns
Copy link
Member

@rafaqz rafaqz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. We can delete the function from Rasters then and use this

elseif Tables.istable(x) && Tables.hascolumn(x, first(GI.geometrycolumns(x)))
return Tables.getcolumn(x, first(GI.geometrycolumns(x)))
else
c = collect(x)
Copy link
Member

@rafaqz rafaqz Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to skip this if x is already an AbstractArray, you can have a do nothing condition

if GI.isgeometry(x)
return x
# elseif GI.isgeometrycollection(x)
# return GI.getgeom(x)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would need collect, and needs to be checked first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants